def num_jewels_in_stones(jewels, stones):
    # 使用集合来记录宝石类型，因为集合的查找操作是O(1)时间复杂度
    jewel_set = set(jewels)
    
    # 初始化宝石数量
    jewel_count = 0
    
    # 遍历石头字符串
    for stone in stones:
        # 检查当前石头是否是宝石
        if stone in jewel_set:
            jewel_count += 1
    
    # 返回宝石数量
    return jewel_count

# 测试例子
jewels1 = "aA"
stones1 = "aAAbbbb"
print(num_jewels_in_stones(jewels1, stones1))  # 输出：3

jewels2 = "z"
stones2 = "ZZ"
print(num_jewels_in_stones(jewels2, stones2))  # 输出：0